class Info{
  constructor(ctx){
    this.ctx = ctx;
    // this.ctx.fillStyle = 'black';
    this.img = new Image();
    this.img.src ='images/bg.jpg';
    this.init = {
      x: this.ctx.canvas.width / 2,
      y: this.ctx.canvas.height / 2,
      w: 300,
      h: 300
    },
      this.btnArea = {
        startX: this.init.x - 40,
        startY: this.init.y - 100 + 180,
        endX: this.init.x + 50,
        endY: this.init.y - 100 + 255
      }
  }
  showScore(score){
    this.ctx.font ='26px 微软雅黑';
    let scoreInfo = '当前分数 :' + score;
    this.ctx.strokeText(scoreInfo, 10, 30);
  }
  //游戏结束并显示状态
  showGameOver(score) {
    this.ctx.drawImage(this.img, 0, 0, 119, 108, this.init.x - 150, this.init.y - 100, 300, 300);
    
    this.ctx.font = '24px 宋体';
    this.ctx.fillStyle = '#bbada0';
    this.ctx.strokeText('游戏结束', this.init.x - 40, this.init.y - 100 + 50);
    this.ctx.strokeText('得分: ' + score, this.init.x - 40, this.init.y - 100 + 130);
    this.ctx.drawImage(this.img, 120, 6, 39, 24, this.init.x - 60, this.init.y - 100 + 180, 120, 40);
    this.ctx.strokeText('重新开始', this.init.x - 40, this.init.y - 100 + 205);
    this.ctx.strokeStyle = '#bbada0';
    this.ctx.lineWidth = 10;
    this.ctx.lineJoin = 'round';
  }
}
export default Info;